package copyengine.ui.component.progress.animation
{
    import copyengine.utils.CEConst;

    import starling.display.DisplayObject;

    public class CEChangeSizeProgressBarAnimation implements ICEProgressBarAnimation
    {
        private var mTarget:DisplayObject;
        private var mDirection:int;
        private var mDefaultSize:Number;

        public function CEChangeSizeProgressBarAnimation()
        {
        }

        public function initialize(_target:DisplayObject, _direction:int):void
        {
            mTarget = _target;
            mDirection = _direction;
            mDefaultSize = mDirection == CEConst.DIR_HORIZONTAL ? _target.width : _target.height;
        }

        public function onPercentChange(_nowPercent:Number):void
        {
            if (mDirection == CEConst.DIR_HORIZONTAL) {
                mTarget.width = mDefaultSize * _nowPercent * 0.01;
            } else {
                mTarget.height = mDefaultSize * _nowPercent * 0.01;
            }
        }
    }
}
